home *** CD-ROM | disk | FTP | other *** search
/ GFX Sensations 1 / Graphic Sensations - Volume 1.iso / tools / amiga / 3d_tools / irit40s.lha / Irit / coding.std < prev    next >
Encoding:
Text File  |  1993-12-30  |  2.8 KB  |  157 lines

  1. These are the coding standards I am using. If you make some changes to the
  2. code, please attempt to follow these rules.
  3.  
  4. Gershon Elber
  5.  
  6. gershon@cs.technion.ac.il
  7.  
  8. ------------------------------------------------------------------------------
  9.  
  10.  
  11. GENERAL
  12. -------
  13.  
  14.     Code should not exceed column 80. If the code is going to "look"
  15.     better with more that 80 columns it is allowed but should be restricted
  16.     as possible.
  17.  
  18. NESTING
  19. -------
  20.     Nesting of all expressions is by 4 spaces. Tabs used are 8 spaces.
  21.  
  22. COMMENTS
  23. --------
  24.  
  25.     Function comments will have the following form:
  26.  
  27. SPACES
  28. ------
  29.     No spaces are allowed after '(' and before ')' in a function call
  30.     or math expression. However, spaces are allowed between arguments after
  31.     the comma or between operations:
  32.  
  33.     sin(x);
  34.     function1(x, y, z);
  35.     x + 5 * sin(y);
  36.  
  37. /*****************************************************************************
  38. * Comment body.                                     *
  39. *****************************************************************************/
  40.  
  41.     Internal comments will be aligned to the right to column 80 if the
  42.     are commenting expression in the same line:
  43.  
  44.     i %= 2;                               /* Is i even? */
  45.  
  46.     Comments that explains the following block, will be left aligned as
  47.     the block. The comment does not need to be right aligned to column 80 as
  48.     well:
  49.  
  50.     /* This is a comment for the next line. */
  51.     i %= 2;
  52.  
  53. BLOCKS
  54. ------
  55.     Blocks starts with '{' and ends with '}'. If the block is beginning
  56.     of procedure then it will start with '{' at column 1 and end at column
  57.     1 with '}'. Otherwise it will start with some expression as for/if/while
  58.     etc. in the nesting form:
  59.     expression {
  60.     .
  61.     .
  62.     .
  63.     }
  64.  
  65. FOR
  66. ---
  67.     for (x = 0; x < 10; x++)
  68.  
  69.     or
  70.     for (x = 0, i = 1;
  71.          x < 5;
  72.          x++, i--)
  73.  
  74.     The body of the for loop can never be in the same line where the ')'
  75.     is. The ')' will be followed by '{' and the body will start in the next
  76.     line nested 4 space deapper:
  77.  
  78.     for (....)
  79.         x = sin(j);
  80.     or
  81.     for (....) {
  82.         x = y / j;
  83.         y = j + 2;
  84.     }
  85.  
  86. WHILE
  87. -----
  88.     while (x > 0)
  89.         x--;                    /* Use x = 0 stupid! */
  90.     or
  91.     while (x > 0 && y > 0) {
  92.         x -= 4;
  93.         y -= 4;
  94.     }
  95.     or
  96.     while (x > 0 &&
  97.            x < 5)
  98.         x /= 2;
  99.  
  100.  
  101. IF
  102. --
  103.  
  104.     if (x > 0)
  105.         x = -x;
  106.     or
  107.     if (x > 0 && y > 0) {
  108.         x = -x;
  109.         y = -y;
  110.     }
  111.     or
  112.     if (x > 0)
  113.         x = -x;
  114.     else
  115.         x /= 2;
  116.     or
  117.     if (x > 0)
  118.         x = -x;
  119.     else if (x < -100)
  120.         x /= 20;
  121.     else
  122.         x /= 2;
  123.  
  124.  
  125.     Note that if the if expression has else part both bodies will be
  126.     aligned 4 space deep (The body of the if part can not be in same line
  127.     as the if and must be aligned with the else body).
  128.  
  129.  
  130. SWITCH
  131. ------
  132.  
  133.     switch (i) {
  134.         case 1:
  135.         printf("1");
  136.         break;
  137.         case 2:
  138.         printf("2");
  139.         break;
  140.         case 3:
  141.         printf("3");
  142.         break;
  143.         default:
  144.         printf("Too big");
  145.         break;
  146.     }
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.